
export const columns = ctx => {
  return [
    {
      type: 'expand',
      width: 120,
      renderHead: (h, row, index) => {
        return (
          <el-link
            underline={false}
            type="primary"
            onClick={() => { ctx.operation('expand', row) }}>
            {ctx.headTxt}</el-link>
        )
      },
      render: (h, row, index) => {
        const list = [].concat(
          row.children && row.children.length ? (
            row.children.map((e, idx) => {
              return (
                <div
                  key={idx}
                  class={{
                    pb10: true,
                    pt10: idx !== 0,
                    bt: idx !== 0,
                    tc: true,
                    wp90: true,
                    fr: true,
                    'row-bettow': true
                  }}
                >
                  <span class='w400'>{e.name}</span>
                  <zm-button
                    type='text'
                    onClick={() => ctx.secondOperation('look', e, idx)}
                    class='flex-one tc heigth_25'
                  >
                    <span class='fc6'>产品数量：</span>
                    {e.productNumber || 0}
                  </zm-button>
                  <div class='w300 tc'>
                    <el-link
                      underline={false}
                      type="primary"
                      class="mr10"
                      onClick={() => { ctx.secondOperation('edit', e, idx, row) }}>
                      编辑</el-link>
                    <el-link
                      underline={false}
                      type="primary"
                      class="mr10"
                      onClick={() => { ctx.secondOperation('del', e, idx, row) }}>
                      删除</el-link>
                  </div>
                </div>
              )
            })
          ) : (
            <div class='fc9 tc'>暂无数据</div>
          )
        )
        return <div>{list}</div>
      }
    },
    {
      prop: 'name',
      label: '产品分类'
    },
    {
      prop: 'createTime',
      label: '创建时间'
    },
    {
      prop: 'productNumber',
      label: '关联产品'
      // render: (h, row) => {
      //   return (
      //     <el-link
      //       underline={false}
      //       type="primary"
      //       class="mr10"
      //       onClick={() => { ctx.operation('look', row) }}
      //     >
      //       {row.productNumber }
      //     </el-link>
      //   )
      // }
    },
    {
      label: '操作',
      render: (h, row, index) => {
        return [
          <el-link
            underline={false}
            type="primary"
            class="mr10"
            onClick={() => { ctx.operation('addSecond', row) }}
          >
            新增二级类目
          </el-link>,
          <el-link
            underline={false}
            type="primary"
            class="mr10"
            onClick={() => { ctx.operation('edit', row) }}
          >
            编辑
          </el-link>,
          <el-link
            underline={false}
            type="primary"
            class="mr10"
            onClick={() => { ctx.operation('del', row) }}
          >
          删除
          </el-link>
        ]
      }
    }
  ]
}
// 新增二级类目产品展示列表
export const secondColumns = (ctx) => {
  return [
    {
      prop: 'productCode',
      label: '产品编号'
    },
    {
      prop: 'name',
      label: '产品名称'
    },
    {
      prop: 'typeName',
      label: '产品类型'
    },
    {
      prop: 'businessTypeName',
      label: '业务类型'
    },
    {
      prop: 'theoryCostPrice',
      label: '理论成本'
    },
    {
      prop: 'practiceCostPrice',
      label: '实际成本'
    },
    {
      prop: 'parValue',
      label: '产品面值'
    },
    {
      prop: 'apartmentName',
      label: '可售部门'
    },
    {
      prop: 'exchangeRangeName',
      label: '兑换范围'
    },
    {
      label: '操作',
      render: (h, row, index) => {
        return [
          <el-link
            underline={false}
            type="primary"
            onClick={() => { ctx.onDel(row) }}
          >
            删除
          </el-link>
        ]
      }
    }
  ]
}
